/**
 * @file:    ring_queue.h
 * @author:  Garry Meng
 * @date:    2025-08-04
 * @brief:   ring queue management
 *
 * Copyright (c) 2025, Garry Meng, <menggaoling@163.com>
 *
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
 * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
 * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 *
**/

#ifndef __RING_QUEUE_H__
#define __RING_QUEUE_H__

#ifndef uint8
typedef unsigned char         uint8;         /*           0..255            */
#endif // !uint8

#ifndef uint16
typedef unsigned short        uint16;        /*           0..65535          */
#endif // !uint16

#ifndef bool
#define bool        uint8
#endif

#ifndef true
#define true        1
#endif

#ifndef false
#define false       0
#endif




typedef struct
{
    uint8* data;
    uint16 front;
    uint16 rear;
    uint16 queue_size;
    uint16 queue_count;
}QUEUE_TYPE;

void ringQueueInit(QUEUE_TYPE* queue, uint8* data, uint16 queue_size);
bool enQueue(QUEUE_TYPE* queue,uint8 value);
bool deQueue(QUEUE_TYPE* queue);
uint8 getQueueFirst(QUEUE_TYPE* queue);
bool isQueueEmpty(QUEUE_TYPE* queue);
bool isQueueFull(QUEUE_TYPE* queue);
uint16 getQueueLength(QUEUE_TYPE* queue);
uint16 getQueueRemainSize(QUEUE_TYPE* queue);

#endif // __RING_QUEUE_H__
